from tkinter import *
import tkinter.messagebox
password_re = '1234'
open('请复制.txt', 'w',encoding='utf-8')
# 实现功能
def writes(write_num,write_things):
    try:
        book = open('请复制.txt', 'r+',encoding='utf-8')
        for i in range(write_num):
            book.write(write_things)
        book.close()
    except:
        tkinter.messagebox.showerror("错误","这绝对不是复制姬的问题！")
    else:
        print("成功")


#操作界面
def function():
    global thing
    global num_in
    w = Tk()
    w.geometry("400x160")
    w.title("复制姬")  
    label1 = Label(w, text='请输入内容：', font=('Arial', 14)).place(x=10, y=10)
    label2 = Label(w, text='请输入遍数：', font=('Arial', 14)).place(x=10, y=50)
    thing = Entry(w,font=('Arial', 14))
    thing.place(x=120,y=15)
    num_in = Entry(w,font=('Arial', 14))
    num_in.place(x=120,y=55)

    def gets():
        global thing
        global num_in
        things = thing.get()
        try:
            num = int(num_in.get())
        except:
            tkinter.messagebox.showerror("错误","hentai！无路赛！你在下面塞别的东西干嘛？")
        else:
            writes(num,things)

    Button(w,text="复制！",font=('Arial', 14),command=gets).place(x=160,y=90)
    Label(w,text="copyright bilibili-whtry陈",font=("微软雅黑",10)).place(x=240,y = 135)

#密码界面
menu = Tk()
menu.geometry("200x110")
menu.title("复制姬")
Label(menu,text="请输入密码",font=("微软雅黑",10)).pack()
password_in = Entry(menu,show="*")
password_in.pack()

def get_password():
    global password
    password = password_in.get()
    if password == '':
        tkinter.messagebox.showerror("错误","请输入密码，密码b站找whtry陈")
    elif password_re == password:
        menu.destroy()
        function()
    elif password_re != password:
        tkinter.messagebox.showerror("错误","密码错误，密码b站找whtry陈")

Button(menu,text=("登录"),font=("微软雅黑",10),command=get_password).pack()
Label(menu,text="copyright bilibili-whtry陈",font=("微软雅黑",10)).pack()
mainloop()